var e = getApp(), o = e.api,
  is_loading_more = !1, is_no_more = !1;
Page({
    data: {
      flag:0
    },
  //点击切换显示内容
    flagFun: function (e) {
      var that = this;
      var name = e.currentTarget.dataset.name;
      var id = e.currentTarget.dataset.id;
      wx.setStorageSync('status', e.currentTarget.dataset.flagindex)
      that.setData({
        flag: e.currentTarget.dataset.flagindex,
      });
      that.loadData(e.currentTarget.dataset.flagindex)
    },
    cardBag(e){
      console.log(111)
      var id = e.currentTarget.dataset.id;
      wx.navigateTo({
        url: '/pages/cardBag/cardBag?id='+ id,
        success: function(res) {},
        fail: function(res) {},
        complete: function(res) {},
      })
    },
    onLoad: function(o) {
      var that= this;
      that.loadData(0);
    },
    onReady: function() {
       // e.pageOnReady(this);
    },
    onShow: function() {
        //e.pageOnShow(this),
      // var status = wx.getStorageSync('status');
      // this.loadData(status);
    },
    loadData: function(status) {
      console.log(status,555);
        var n = this;
      var t = getApp().getUser();
        wx.showLoading({
            title: "加载中"
        }),
          e.request({
            url: o.order.member_orders,
            method: "post",
            data: {
              userid:t.id,
              status: status,
            },
            success: function (e) {
              console.log(1111,e);
              if (0 == e.code) {
                wx.hideLoading();
                n.setData({
                  user_coupon:e.data
                })
              } else wx.showToast({
                title: "网络错误",
                image: "/images/icon-warning.png"
              });
            }
          });
        //  e.request({
        //     url: o.user.user_coupon,
        //     method: "GET",
        //     data: {
        //         page: 1
        //     },
        //     success: function(e) {
        //         if (0 == e.code) {
        //             for (var o = Math.round(new Date().getTime() / 1e3).toString(), t = e.data.user_coupon, a = t.length, i = 0; i < a; i++) o > t[i].endtime && (t[i].is_expire = 1);
        //             n.setData({
        //                 user_coupon: t
        //             }), wx.hideLoading();
        //         } else wx.showToast({
        //             title: "网络错误",
        //             image: "/images/icon-warning.png"
        //         });
        //     }
        // });
    },
    coupon_qrcode: function(n) {
        var t = this, a = n.currentTarget.dataset;
        e.request({
            url: o.user.user_coupon_qrcode,
            method: "GET",
            data: {
                user_coupon_id: a.id
            },
            success: function(e) {
                0 == e.code ? t.setData({
                    user_coupon_qrcode: e.data.pic_url,
                    showModel: !0
                }) : wx.showToast({
                    title: "网络错误",
                    image: "/images/icon-warning.png"
                });
            }
        });
    },
    preventTouchMove: function() {},
    hideModal: function() {
        this.setData({
            showModel: !1
        });
    },
    onHide: function() {
        //e.pageOnHide(this);
    },
    onUnload: function() {
        e.pageOnUnload(this);
    },
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {}
});